﻿$(function () {
    $("#tabTitle").children().each(function () {
        $(this).attr("tagName") == "A" && $(this).click(function () {
            var tabContentId = "__" + $(this).text();
            $("#tabContent").children().each(function () {
                if ($(this).attr("id") != tabContentId && $(this).attr("open") == "true") {
                    $(this).fadeOut(300, function () {
                        $("#" + tabContentId).fadeIn();
                        $("#" + tabContentId).attr("open", "true");
                    });
                    $(this).removeAttr("open");
                }
            });
        });
    });
});

if (!document.all) document.captureEvents(Event.MOUSEDOWN);
var _Tmenu = 0;
var _Amenu = 0;
var _Type = 'A';
var _Menu = "null";
document.onclick = _Hidden;
function _Hidden() {
    if (_Tmenu == 0) return;
    document.getElementById(_Tmenu).style.visibility = 'hidden';
    _Tmenu = 0;
}

document.oncontextmenu = function (e) {
    _Hidden();
    var _Obj = document.all ? event.srcElement : e.target;
    if (_Type.indexOf(_Obj.tagName) == -1) return;
    _Amenu = _Obj.getAttribute('menu');
    if (_Amenu == 'null') return;
    if (document.all) e = event;
    _ShowMenu(_Amenu, e);
    return false;
}
function _ShowMenu(Eid, event) {
    _Menu = document.getElementById(Eid);

    var _Left = event.clientX + document.body.scrollLeft;
    var _Top = event.clientY + document.body.scrollTop;
    _Menu.style.left = _Left.toString() + 'px';
    _Menu.style.top = _Top.toString() + 'px';
    _Menu.style.visibility = 'visible';
    _Tmenu = Eid;
    _Menu.onclick = transfer;
    _Menu.oncontextmenu = no_context_menu;
}

function transfer(e) {
    e = e || window.event; e.cancelBubble = true;
}

function no_context_menu(e) {
    e = e || window.event;
    e = e || window.event; e.cancelBubble = true;
    return;
}